﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Meqs.Entity;
using Meqs.Logic.Interface;

namespace Meqs.Logic.Implement
{
    public class ClassEvalTypeLogic : CommonLogic<ClassEvalType, int>, IClassEvalTypeLogic
    {
        #region Implementation of ICommonLogic<ClassEvalType, int>

        /// <summary>
        /// 创建对象
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(ClassEvalType entity)
        {
            return CreateObject(entity);
        }

        /// <summary>
        /// 更新对象
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(ClassEvalType entity)
        {
            return UpdateObject(entity);
        }

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public int Delete(int entityId)
        {
            return DeleteObject(entityId);
        }

        /// <summary>
        /// 删除所有对象
        /// </summary>
        /// <returns></returns>
        public int DeleteAll()
        {
            return DeleteAllObject();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public ClassEvalType FindById(int entityId)
        {
            return FindObjectById(entityId);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount()
        {
            return FindObjectByCount();
        }

        /// <summary>
        /// 检索对象
        /// </summary>
        public IList<ClassEvalType> FindAll()
        {
            return FindAllObject();
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        /// <summary>
        /// 检索对象
        /// </summary>
        public IList<ClassEvalType> FindAll(Hashtable table)
        {
            return FindObject(table);
        }

        #endregion
        /// <summary>
        /// 验证名字重复
        /// </summary>
        /// <param name="p"></param>
        /// <param name="historyId"></param>
        /// <param name="causeId"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public int ValidateTypeName(string p, int historyId, string typeName)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", p);

            table.Add("historyId", historyId);
            table.Add("typeName", typeName);
            int result = 0;
            try
            {
                result = FindCustomerByCount("ClassEvalType.ValidateTypeName", table);
            }
            catch (Exception e)
            {
                throw;
            }

            return result;
        }
        /// <summary>
        /// 插入类型
        /// </summary>
        /// <param name="p"></param>
        /// <param name="historyId"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public int InsertType(string p, int historyId, string typeName)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", p);
            table.Add("historyId", historyId);
            table.Add("typeName", typeName);
            int result = 0;
            try
            {
                result = (int)InsertCustomer("ClassEvalType.InsertType", table);
            }
            catch (Exception e)
            {
                throw;
            }

            return result;
        }


        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ht"></param>
        /// <returns></returns>
        public int Delete(Hashtable ht)
        {
            try
            {
                string statementName = "ClassEvalType.DeleteById";
                return ExecuteDelete(statementName, ht);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        /// <summary>
        /// 更新名字
        /// </summary>
        /// <param name="ht"></param>
        /// <returns></returns>
        public int UpdateTypeName(Hashtable ht)
        {
            try
            {
                string statementName = "ClassEvalType.UpdateName";
                return ExecuteUpdate(statementName, ht);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        /// <summary>
        /// 获取所有ClassEvalType的项
        /// </summary>
        /// <param name="schoolMark"></param>
        /// <param name="schoolYear"></param>
        /// <param name="term"></param>
        /// <returns></returns>
        public IList<ClassEvalType> GetAllClassEvalType(int historyId, string schoolMark, int schoolYear, int term)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", schoolMark);
            table.Add("SchoolYear", schoolYear);
            table.Add("Term", term);
            table.Add("historyId", historyId);

            return FindCustomer<ClassEvalType>("ClassEvalType.GetAllClassEvalType", table);
        }
    }
}
